package com.haoze.nurseapp.controller;


import com.alibaba.fastjson.JSON;
import com.haoze.common.enumeration.StateEnum;
import com.haoze.common.response.Result;
import com.haoze.common.response.ResultGenerator;
import com.haoze.nurseapp.dto.DeliveryInputDTO;
import com.haoze.nurseapp.dto.PatientTemperatureConfigDTO;
import com.haoze.nurseapp.dto.PatientTemperatureDTO;
import com.haoze.nurseapp.enumeration.OralEnum;
import com.haoze.nurseapp.service.OralMedicineService;
import com.haoze.nurseapp.service.PatientService;
import com.haoze.nurseapp.service.PatientTemperatureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/nurseapp/temperature")
@Api(value = "病人体温单接口")
public class PatientTemperatureController {

    @Autowired
    PatientTemperatureService patientTemperatureService;


    @Autowired
    PatientService patientService;

    @PostMapping("/save")
    @ApiOperation(value = "体温单录入保存")
    public Result save(@RequestBody PatientTemperatureDTO patientTemperature) {
        return patientTemperatureService.temperatureSave(patientTemperature);
    }

    @GetMapping("/getNearTime")
    @ApiOperation(value = "获取距离当前最近的测量时间")
    public Result getNearTime() {
        return patientTemperatureService.getNearTime();
    }

    @PostMapping("/configList")
    @ApiOperation(value = "获取体温单配置")
    public Result configList(@RequestBody PatientTemperatureConfigDTO dto) {
        return patientTemperatureService.queryTemperatureConfig(dto);
    }

    @PostMapping("/configUpdate")
    @ApiOperation(value = "修改体温单配置")
    public Result configUpdate(@RequestBody List<PatientTemperatureConfigDTO> dtolist) {
        return patientTemperatureService.updateTemperatureConfig(dtolist);
    }

    @PostMapping("/configSave")
    @ApiOperation(value = "新增体温单配置")
    public Result configsave(@RequestBody PatientTemperatureConfigDTO dto) {
        return patientTemperatureService.saveTemperature(dto);
    }

    @PostMapping("/configDelete")
    @ApiOperation(value = "删除体温单配置")
    public Result configdelete(@RequestBody List<PatientTemperatureConfigDTO> dto) {
        return patientTemperatureService.deleteTemperature(dto);
    }

    @GetMapping("/drugList")
    @ApiOperation(value = "获取药品列表--皮试下拉选")
    public Result drugList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "50") Integer pageSize,@RequestParam(required = false) String keyWords) {
        return patientTemperatureService.getDrugList(page,pageSize,keyWords);
    }

    @GetMapping("/fileData")
    @ApiOperation(value = "获取病人最新护理记录单体征数据")
    public Result fileData(@RequestParam String inpatNum,@RequestParam String date) {
        return patientTemperatureService.getNurseFileData(inpatNum,date);
    }

    @GetMapping("/selectVolume")
    @ApiOperation(value = "查询出入量")
    public Result selectVolume(@RequestParam String inpatNum) {
        inpatNum = inpatNum + "-1";
        return patientTemperatureService.selectVolume(inpatNum);
    }

    @GetMapping("/queryTimeData")
    @ApiOperation(value = "获取时刻温度数据")
    public Result queryTimeDate(@RequestParam String inpatNum,@RequestParam String date) {
        return patientTemperatureService.queryTimeData(inpatNum,date);
    }

    @GetMapping("/queryTimeDataForPc")
    @ApiOperation(value = "获取时刻温度数据PC")
    public Result queryTimeDataForPc(@RequestParam String inpatNum,@RequestParam String day) {
        return patientTemperatureService.queryTimeDataForPc(inpatNum,day);
    }

    @GetMapping("/queryTimeForDelivery")
    @ApiOperation(value = "获取分娩时刻和回室时刻")
    public Result queryTimeForDelivery(@RequestParam String inpatNum) {
        return patientTemperatureService.queryTimeForDelivery(inpatNum);
    }

    @PostMapping("/saveTimeForDelivery")
    @ApiOperation(value = "保存分娩时刻和回室时刻")
    public Result saveTimeForDelivery(@RequestBody DeliveryInputDTO deliveryInputDTO) {
        return patientTemperatureService.saveTimeForDelivery(deliveryInputDTO);
    }
}